home *** CD-ROM | disk | FTP | other *** search
- /* XMenu.h
- *
- * This contains the various menu handling classes.
- *
- * How this works:
- *
- * Okay, okay, so I really don't make the menu bar into a linked
- * list of objects totally under my control. Though it certainly would
- * be a hell of a lot easier.
- *
- * Instead, I represent the menu bar's structure through using
- * these structures. Then, when it's time to throw the menu bar up
- * on the display, I convert the structure into the system's native
- * menu representation.
- */
-
- /* YAAF - Yet another application framework
- * Copyright (C) 1997 William Edward Woody and In Phase Consulting
- *
- * This library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Library
- * General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or any
- * later version.
- *
- * This library is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Library General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * To contact the author, either e-mail me at
- * woody@alumni.caltech.edu, or write to us at
- *
- * William Edward Woody
- * In Phase Consulting
- * 1545 Ard Eevin Avenue
- * Glendale, CA 91202
- */
-
- #ifndef __XMENU_H__
- #define __XMENU_H__
-
- #include <XDynArray.h>
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=power
- #endif
- #if defined(__INTEL__)
- #pragma pack(push,2)
- #endif
- #endif
-
- /************************************************************************/
- /* */
- /* Forwards */
- /* */
- /************************************************************************/
-
- class XGFocus;
-
- /************************************************************************/
- /* */
- /* Internal Support Classes */
- /* */
- /************************************************************************/
-
- #if OPT_MACOS == 1
-
- /* _MenuIDArray
- *
- * Because the Macintosh OS doesn't allow me to store command IDs
- * in the menu bar itself
- */
-
- struct _MenuIDArray {
- short menuID; /* ID of this menu */
- XGDynArray<long> itemID; /* The command IDs */
- };
-
- #endif
-
- /************************************************************************/
- /* */
- /* Menu Bar Declaration */
- /* */
- /************************************************************************/
-
- /* XGMenuBar
- *
- * This is an abstraction for a menu bar. A menu bar is the
- * actual resource, along with methods for modifying the contents.
- *
- * The menu identifier is an opaque value; it should be treated
- * as such. On the Macintosh, this is the MenuHandle to the menu being
- * manipulated; on the PC it's a HMENU, and on X Windows it's God Knows
- * What.
- *
- * We assume that the menu bar object is mapped one-to-one with
- * the actual menu bars used in the application; in most instances,
- * that means this is a global object, though it doesn't have to be.
- * (For example, on a multi-window X Windows application, we may have
- * one of these per window--I don't know.)
- */
-
- class XGMenuBar {
- public:
- /*
- * Construction routines
- */
-
- #if OPT_MACOS == 1
- XGMenuBar();
- #endif
-
- #if OPT_WINOS == 1
- XGMenuBar(bool,HWND);
- #endif
-
- virtual ~XGMenuBar();
-
- /*
- * Resource manipulation
- */
-
- void _LoadFromResource(short);
-
- /*
- * Manipulation of the menus
- */
-
- long GetNumMenus(); /* # menus in me */
- long GetMenu(short); /* Get menu by index*/
-
- /*
- * Manipulation of the contents (item is zero-based)
- */
-
- short GetNumItems(long); /* # items in menu */
-
- void SetItemID(long,short,long);
- long GetItemID(long,short);
-
- void SetItemText(long,short,char *);
- void GetItemText(long,short,char *);
-
- void SetItemShortcut(long,short,char);
- char GetItemShortcut(long,short);
-
- long GetSubMenu(long,short);
-
- /*
- * Insertion/Deletion
- */
-
- void InsertMenuItem(long,short);
- void DeleteMenuItem(long,short);
-
- /*
- * Menu Support
- */
-
- void _UpdateMenuBar(XGFocus *);
-
- #if OPT_MACOS == 1
- void _DispatchCommand(XGFocus *,short,short);
- #endif
-
- private:
- /*
- * Private stuff
- */
-
- short fCurResID;
-
- #if OPT_MACOS == 1
- _MenuIDArray *GetMenuArray(short);
- void UpdateMenu(XGFocus *,MenuHandle mh);
-
- short fApplMenu;
- short fApplLen;
- XGDynArray<MenuHandle> fMenuBar;
- XGDynArray<MenuHandle> fHidden;
- XGDynArray<_MenuIDArray *> fCommands; // Mac command codes
- #endif
-
- #if OPT_WINOS == 1
- bool fMDIWindowFlag;
- HMENU fMenuHandle;
- HWND fMenuWindow;
-
- bool IsZoomed();
- int UpdatePopUpMenu(XGFocus *, HMENU, short);
- #endif
- };
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=reset
- #endif
- #if defined(__INTEL__)
- #pragma pack(pop)
- #endif
- #endif
-
-
- #endif /* __XMENU_H__ */
-